<?php

namespace Modules\Shop\Http\Controllers;

use Illuminate\Support\Facades\Request;
use Modules\Shop\Service\AuthorService;
use HiCommon\Service\PublicService;
use Modules\Shop\Service\ShopService;

class AuthorController extends BaseController
{
    /**
     * 管理员详情(检测机构信息)
     */
    public function checkpointDetail()
    {
        $admin = shop_user();//当前管理员信息
        $detail = AuthorService::getShopCheckDetail(['id' => $admin->shop_id]);//检测机构信息

        $detail['province'] = PublicService::getProvinceList();//省列表
        $detail['city'] = PublicService::getCityAraeList(['pid' => $detail['detail']['province']]);//城市
        $detail['area'] = PublicService::getCityAraeList(['pid' => $detail['detail']['city']]);//县

        return view('shop::author.checkpointDetail', $detail);
    }

    /**
     * 检测机构管理员编辑详情
     */
    public function checkUpdate()
    {
        $data = Request::all();

        shiwu_start();
        $res = AuthorService::checkUpdate($data);
        shiwu_end($res);

        return $res;
    }

    /**
     * 管理员详情(维修店信息)
     */
    public function repairStoreDetail()
    {
        $admin = shop_user();//当前管理员信息

        $detail = AuthorService::getShopDetail(['id' => $admin->shop_id]);//维修店信息

        $detail['province'] = PublicService::getProvinceList();//省列表
        $detail['city'] = PublicService::getCityAraeList(['pid' => $detail['detail']['province']]);//城市
        $detail['area'] = PublicService::getCityAraeList(['pid' => $detail['detail']['city']]);//县

        return view('shop::author.repairstoreDetail', $detail);
    }

    /**
     * 维修店管理员编辑详情
     */
    public function repairUpdate()
    {
        $data = Request::all();

        shiwu_start();
        $res = AuthorService::repairUpdate($data);
        shiwu_end($res);

        return $res;
    }

    /**
     *地图坐标拾取
     */
    public function openMap()
    {
        $lonlat = $data = Request::all();
        return view('shop::author.map', $lonlat);
    }

    /**
     *删除服务类型
     */
    public function delService($id)
    {
        return CheckpointService::delService($id);
    }

    /**
     * 检测手机号或门店名称是否存在
     */
    public function dataMonitoring()
    {
        $data = Request::all();

        $res = ShopService::dataMonitoring($data);

        return response_json($res);
    }
}
